<template>
  <el-form-item v-show="isShow" label="">
    <el-button
      type="info"
      icon="el-icon-edit"
      plain
      round
      @click="editEventHandler('eventCode', eventParams)"
    >
      {{ i18nt('designer.setting.addEventHandler') }}</el-button
    >
  </el-form-item>
</template>

<script>
import eventMixin from '@/mixins/eventMixin'

export default {
  name: 'EventCodeEditor',
  mixins: [eventMixin],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object
  },
  data() {
    return {
      eventParams: []
    }
  },
  computed:{
    isShow() {
      // Hide when:
      // 1. Component is 'number' and isInput is 0
      // 2. Component is 'text' and isInput is 0
      if (this.selectedWidget) {
        if (
          (this.selectedWidget.type === 'number' && 
           this.selectedWidget.options.isInput === 0) ||
          (this.selectedWidget.type === 'text' && 
           this.selectedWidget.options.isInput === 0)
        ) {
          return false
        }
      }
      return true
    }
  }

}
</script>

<style scoped></style>
